//package com.sunday.volunteer.ui;
//
//import android.content.Context;
//import android.os.Bundle;
//import android.support.v4.widget.SwipeRefreshLayout;
//import android.support.v7.widget.GridLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.text.TextUtils;
//import android.view.KeyEvent;
//import android.view.inputmethod.EditorInfo;
//import android.view.inputmethod.InputMethodManager;
//import android.widget.TextView;
//
//import com.sunday.common.widgets.EmptyLayout;
//import com.sunday.member.base.BaseActivity;
//import com.sunday.volunteer.R;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import butterknife.Bind;
//import butterknife.ButterKnife;
//import retrofit2.Call;
//import retrofit2.Callback;
//import retrofit2.Response;
//
//
///**
// * Created by Pual's PC on 2016/8/2.
// */
//public class SearchActivity extends BaseActivity {
//
////    @Bind(R.id.recycler_view)
////    RecyclerView recyclerView;
////    @Bind(R.id.swipfresh_layout)
////    SwipeRefreshLayout swipeRefreshLayout;
////    @Bind(R.id.edit_text)
////    EditText editText;
////    @Bind(R.id.empty_layout)
////    EmptyLayout emptyLayout;
////
////    private int pageNo ;
////    private ProductListAdapter adapter;
////    private List<Product> list;
//
//    private RecyclerView.LayoutManager layoutManager;
//    private String name;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_search);
//        ButterKnife.bind(this);
////
////        list = new ArrayList<>();
////        adapter = new ProductListAdapter(list , R.layout.item_shop_product);
////        layoutManager = new GridLayoutManager(mContext , 2);
////        recyclerView.setLayoutManager(layoutManager);
////        recyclerView.setHasFixedSize(true);
////        swipeRefreshLayout.setColorSchemeResources(R.color.material_red, R.color.material_green,
////                R.color.material_blue, R.color.material_yellow);
////        recyclerView.setAdapter(adapter);
////
////        editText.setOnEditorActionListener(onEditorActionListener);
////        BaseUtil.setEmptyLayout(emptyLayout , list.size() , null);
//        handlerRecyclerView();
//    }
////
////    TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {
////        @Override
////        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
////            if(TextUtils.isEmpty(editText.getText().toString())){
////                return true;
////            }
////            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
////                // 先隐藏键盘
////                ((InputMethodManager) editText.getContext().getSystemService(
////                        Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(SearchActivity.this
////                                .getCurrentFocus().getWindowToken(),
////                        InputMethodManager.HIDE_NOT_ALWAYS);
////
////                pageNo = 1;
////                name = editText.getText().toString();
////                getData();
////                return true;
////            }
////            return true;
////        }
////    };
//
//    private void handlerRecyclerView() {
//        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//            @Override
//            public void onRefresh() {
//                pageNo = 1;
//                getData();
//            }
//        });
//    }
//
//    private void getData(){
//
//        Call<ResultDO<List<Product>>> call = HttpClient.getHttpAdapter().getProductList(3 ,pageNo ,10 ,null ,name);
//        call.enqueue(new Callback<ResultDO<List<Product>>>() {
//            @Override
//            public void onResponse(Call<ResultDO<List<Product>>> call, Response<ResultDO<List<Product>>> response) {
//                if(response.body() == null || isFinish){
//                    return;
//                }
//                if(response.body().getCode() == 0 && response.body().getResult() != null){
//                    if(pageNo == 1){
//                        list.clear();
//                    }
//                    list.addAll(response.body().getResult());
//                    BaseUtil.setEmptyLayout(emptyLayout , list.size() ,null);
//                    adapter.notifyDataSetChanged();
//                }
//                swipeRefreshLayout.setRefreshing(false);
//            }
//
//            @Override
//            public void onFailure(Call<ResultDO<List<Product>>> call, Throwable t) {
//                swipeRefreshLayout.setRefreshing(false);
//                emptyLayout.setErrorType(EmptyLayout.NETWORK_ERROR);
//            }
//        });
//
//    }
//
//}
